#include <iostream>
#include <thread>
#include <future>
#include <unistd.h>

int Add(int num1, int num2)
{
    std::cout << "加法!\n";
    // sleep(1);
    return num1 + num2;
}

int main()
{
    std::cout << "-------1-------\n";
    std::future<int> result = std::async(std::launch::async, Add, 11, 22); // 此时线程没有执行
    sleep(1);
    std::cout << "-------2-------\n";
    int sum = result.get();
    std::cout << "-------3-------\n";
    std::cout << sum << std::endl;
    return 0;
}